package oop.ex2.filters;
/**
 * Filters of comparable type. 
 * @param <Type> Type of data inserted into class.
 */

abstract class ComparableFilter<Type extends Comparable<Type>> extends Filter{
	//********************************************************************
	//  Finals :                                                         *
	//********************************************************************
	public final static int BIGGER = 1;
	public final static int EQUALS = 0;
	public final static int SMALLER = -1;
	
	//********************************************************************
	//  Data members :                                                   *
	//********************************************************************
	protected int _compareMode;
	
	//***********************************************************************
	//  Methods :                                                           *
	//***********************************************************************
	
	/**
	 * Constructs a new filter of comparable type.
	 * @param compareMode The comparison mode - Bigger,Equals,Smaller.
	 */
	public ComparableFilter(int compareMode ){
		super();
		_compareMode = compareMode;
    }
	/**
	 * Sets the condition of the filter.
	 */
	public void calculate(){
	    if ( _file.isDirectory() ) {
	        _condition = STATUS.FALSE;
	        return;
	    }
		if (_compareMode == getFileData().compareTo(getComparableData())){
			_condition = STATUS.TRUE;
		}
		else{
			_condition = STATUS.FALSE;
		}
	}
	/**
	 * Returns file relevant data.
	 * @return File's relevant data.
	 */
	public abstract Type getFileData();
	/**
	 * Returns the value of the filter.
	 * @return Filter's value.
	 */
	public abstract Type getComparableData();
}
